Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs related with SpinRange and flow #488

Merged
merged 5 commits into from
Sep 27, 2024
Merged

Fix bugs related with SpinRange and flow #488

merged 5 commits into from
Sep 27, 2024

Conversation

pvillacorta
Copy link
Collaborator

I discovered these bugs when testing with the artery.phantom (now deleted because of its size, I should upload it to another repository, Zenodo or as an artifact).

Copy link

codecov bot commented Sep 27, 2024

Codecov Report

Attention: Patch coverage is 90.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 90.70%. Comparing base (356c48a) to head (bfbf17c).
Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
KomaMRIPlots/src/ui/DisplayFunctions.jl 60.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #488      +/-   ##
==========================================
+ Coverage   90.27%   90.70%   +0.43%     
==========================================
  Files          54       54              
  Lines        3055     3046       -9     
==========================================
+ Hits         2758     2763       +5     
+ Misses        297      283      -14     
Flag Coverage Δ
base 86.79% <100.00%> (+0.55%) ⬆️
core 93.20% <100.00%> (+0.06%) ⬆️
files 91.69% <ø> (ø)
komamri 93.98% <ø> (ø)
plots 92.98% <60.00%> (+1.65%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
KomaMRIBase/src/motion/motionlist/Motion.jl 85.00% <100.00%> (ø)
KomaMRIBase/src/motion/motionlist/MotionList.jl 67.64% <100.00%> (-20.59%) ⬇️
KomaMRIBase/src/motion/motionlist/SpinSpan.jl 79.16% <100.00%> (+53.07%) ⬆️
KomaMRICore/src/simulation/Flow.jl 100.00% <100.00%> (ø)
KomaMRIPlots/src/ui/DisplayFunctions.jl 94.05% <60.00%> (+1.82%) ⬆️

... and 2 files with indirect coverage changes

@cncastillo
Copy link
Member

cncastillo commented Sep 27, 2024

Can you explain why this check idx !== nothing is needed?

function Base.getindex(m::Motion, p)
    idx, spin_range = m.spins[p]
    return idx !== nothing ? Motion(m.action[idx], m.time, spin_range) : nothing
end

@pvillacorta
Copy link
Collaborator Author

Can you explain why this check idx !== nothing is needed?

function Base.getindex(m::Motion, p)
    idx, spin_range = m.spins[p]
    return idx !== nothing ? Motion(m.action[idx], m.time, spin_range) : nothing
end

I need this when, for example I have a m=Motion with SpinRange(501:1000) and I do m[1:500], that is, when indexing with out-of-range indices. As the intersection between the two ranges is null, the return SpinRange would be SpinRange(0:0), but that makes no sense. So, in that case, it is better to return nothing.
Imagine that this motion is part of a phantom obj with 1000 spins:

julia> obj.motion
MotionList(
   Translate(..., SpinRange(501:1000))
)

When indexing obj[1:500]: the resulting motion should be NoMotion

julia> obj[1:500].motion
NoMotion(...)

@cncastillo
Copy link
Member

cncastillo commented Sep 27, 2024

Ok! Feel free to merge.

@pvillacorta pvillacorta merged commit 48a5bbe into master Sep 27, 2024
19 checks passed
@pvillacorta pvillacorta deleted the fix-spinspan branch September 27, 2024 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants